package com.xca.rxjavademo.views;

import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;


import com.xca.rxjavademo.R;
import com.xca.rxjavademo.adapter.DayImgAdapter;
import com.xca.rxjavademo.base.BaseActivity;
import com.xca.rxjavademo.contract.DayImageContact;
import com.xca.rxjavademo.entity.DayImage;
import com.xca.rxjavademo.presenter.DayImagePresenter;

import java.util.ArrayList;
import java.util.List;

public class DayImageActivity extends BaseActivity implements DayImageContact.DayImageView {
    private TextView mTitle ;
    private RecyclerView mRecycle;
    private DayImageContact.DayImagePresenter mPresenter ;
    private DayImgAdapter adapter ;
    private List<DayImage.ImageData> mList ;
    @Override
    public int getLayoutId() {
        return R.layout.day_image;
    }

    @Override
    public void init() {
        mTitle = findViewById(R.id.mTitle);
        mRecycle = findViewById(R.id.dListView);
        mPresenter = new DayImagePresenter(this , this);
        mPresenter.getData();
        mRecycle.setLayoutManager(new GridLayoutManager(this,2));
        mList = new ArrayList<>();
        adapter = new DayImgAdapter( mList , this , this);
        mRecycle.setAdapter(adapter);
    }

    @Override
    public void showData(DayImage data) {
        mList = data.getResult() ;
        adapter.updateData(mList);
    }
}
